<?php namespace system\model;

use houdunwang\model\Model;

class Tag extends Model
{
	//数据表
	protected $table = "tag";

	/**
	 * 添加
	 */
	public function store ()
	{
		if(strlen($_POST['tname'])==0){
			return ['valid'=>0,'message'=>'请填写标签内容'];
		}
		//var_dump($_POST);die;
		//1.将提交的字符串数据拆成数组
		$tags = explode( '|' , $_POST[ 'tname' ] );
		p($tags);
		//p($tags);
		foreach ( $tags as $k => $v ) {
			//Db::table('user')-> insertGetId(['username'=>'向军','qq'=>'2300071698']);
			$this-> insertGetId(['tname'=>$v]);
		}
		return ['valid'=>1,'message'=>'添加成功'];
	}
}